package jsengine;

import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;

public class Demo {

    public static void main(String[] args) throws Exception {
        execjs();
    }

    public static void execjs() throws Exception {
        ScriptEngineManager scriptEngineManager = new ScriptEngineManager();
        ScriptEngine javaScript = scriptEngineManager.getEngineByName("JavaScript");
        Object o = javaScript.eval("function add(a, b){ return a + b;} add(2, 3);");
        System.out.println(o);
    }

}
